home *** CD-ROM | disk | FTP | other *** search
- Path: acs3.acs.ucalgary.ca!hdang
- From: hdang@acs3.acs.ucalgary.ca (Hanna Dang)
- Newsgroups: comp.lang.c++
- Subject: Overloading conversion
- Date: 13 Jan 1996 20:02:39 GMT
- Organization: The University of Calgary
- Message-ID: <4d934v$10hs@ds2.acs.ucalgary.ca>
- NNTP-Posting-Host: hdang@acs3.acs.ucalgary.ca
- X-Newsreader: TIN [version 1.2 PL2]
-
- Is there a way to overload functions such that certain
- functions are called depending on the context the object are
- used. For example,
-
- class T {
- public:
- int& int_value() { modified = TRUE; return value;}
- int int_value() {return value;}
- private:
- int value;
- int modified;
- }
-
-
- ...
-
- T a;
- int test = a + 6 // int int_value should be called;
- a = 20 // int& int_value should be called.
-
- However, this does not work because in both case int& int_value
- is called. Is there another way to find out if value is changed
- or it's just inspected.
-
-